package cn.pfz.Service.impl;

import cn.pfz.Service.IAppointmentMapperService;
import cn.pfz.domain.Appointment;
import cn.pfz.mapper.AppointmentMapper;
import cn.pfz.query.Businessquery;
import cn.pfz.query.appointmentQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IAppointmentMapperServiceimpl implements IAppointmentMapperService {
    @Autowired
    private AppointmentMapper appointmentMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return appointmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Appointment record) {
        return appointmentMapper.insert(record);
    }

    @Override
    public Appointment selectByPrimaryKey(Long id) {
        return appointmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Appointment> selectAll() {
        return appointmentMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Appointment record) {
        return appointmentMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Appointment> list(appointmentQuery qo) {
        //通过pageHelper进行设置分页及排序
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"id asc");
        //在Sql中不需要limit
        List<Appointment> list = appointmentMapper.selectRusult(qo);
        PageInfo<Appointment> PageInfo = new PageInfo(list);
        return PageInfo;
    }

    @Override
    public void updateStatusById(Appointment appointment) {
        appointmentMapper.updateStatusById(appointment);
    }
}
